package com.gxsyh.nantie.dining.provider.service.impl;
import java.util.Date;

import com.gxsyh.nantie.dining.provider.domain.TbSubsidy;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import com.gxsyh.nantie.dining.provider.mapper.TbSubsidyMapper;
import com.gxsyh.nantie.dining.provider.service.TbSubsidyService;
import tk.mybatis.mapper.entity.Example;

import java.util.List;
import java.util.UUID;

/**
 * @email yom535@outlook.com
 * @author: 刘锋嘉(Liu Fengjia)
 * @date: 2020/1/8
 * @time: 14:54
 * @Description: 
 */
@Service
public class TbSubsidyServiceImpl implements TbSubsidyService{

    @Resource
    private TbSubsidyMapper tbSubsidyMapper;

    @Override
    public List<TbSubsidy> selectDepartmentSubsidy(Long departmentId) {
        return tbSubsidyMapper.selectDepartmentSubsidy(departmentId);
    }

    @Override
    public int deleteSubsidyBySubsidyId(Long subsidyId) {
        Example example=new Example(TbSubsidy.class);
        example.createCriteria().andEqualTo("id",subsidyId);
        return tbSubsidyMapper.deleteByExample(example);
    }

    @Override
    public int insterSubsidyBySubsidyId(Long id,String name,String subsidyMoney,int numberSubsidies,String startime,String endtime) {
        TbSubsidy tbSubsidy = new TbSubsidy();
        tbSubsidy.setId(id);
        tbSubsidy.setName(name);
        tbSubsidy.setEname(UUID.randomUUID().toString());
        tbSubsidy.setSubsidyMoney(subsidyMoney);
        tbSubsidy.setNumberSubsidies(numberSubsidies);
        tbSubsidy.setStartime(startime);
        tbSubsidy.setEndtime(endtime);
        tbSubsidy.setCreatetime(new Date());

        return tbSubsidyMapper.insert(tbSubsidy);
    }
}
